
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fultter/basic/Text.dart';

import 'People_item_page.dart';
import 'email_item_page.dart';
import 'home_item_page.dart';
class ScffoldHomePage extends StatefulWidget {


  @override
  _ScffoldHomePageState createState() => _ScffoldHomePageState();
}

class _ScffoldHomePageState extends State<ScffoldHomePage> {

  /// 当前选中的页面
  num index = 0;
  /// 定义三个页面
  List <Widget> pageWidgetList = [
    HomeItemPage(),
    EmalItemPage(),
    PeopleItemPage(),
  ];
  @override
  Widget build(BuildContext context) {
    /// 使用 Scaffold 组件来构建应用的基本页面
    return Scaffold(
      appBar: AppBar(
        title: Text("这里是首页"),
      ),
      body:pageWidgetList[index],
      // 定义的悬浮按钮
      floatingActionButton: FloatingActionButton(
        child: Text("++"),
        onPressed: (){
          print("点击了 FloatingActionButton");
        },
        tooltip: "点击了 tooltip",
        //设置悬浮按钮的背景
        backgroundColor: Colors.red,
        // 获取焦点时显示的颜色
        focusColor: Colors.yellow,
        /// 水波纹颜色
        splashColor: Colors.deepPurple,
        /// 配置阴影高度
        elevation: 0.0,
        highlightElevation: 20.0,
      ),
      /// 用来控制 FloatingActionButton 的位置
      /// FloatingActionButtonLocation.endFloat 默认使用浮动右下角
      /// FloatingActionButtonLocation.endDocked 右下角
      /// FloatingActionButtonLocation.endTop 右上角
      /// FloatingActionButtonLocation.startTop 左上角
      /// FloatingActionButtonLocation.centerFloat 底部中间浮动
      /// FloatingActionButtonLocation.centerDecked 底部中间不浮动
      floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
      /// 左侧拉菜单页面
      drawer: Container(
        color: Colors.grey,
        width: 120,
        child: FlatButton(
            onPressed: (){
              ///打开左侧菜单
              Navigator.of(context).pop();
            },
            child: Text("关闭左侧菜单")
        ),
      ),
      /// 右侧拉菜单页面
      endDrawer: Container(
        color: Colors.yellow,
        width: 200,
        child: FlatButton(
            onPressed: (){
              ///打开左侧菜单
              Navigator.of(context).pop();
            },
            child: Text("关闭右侧菜单")
        ),

      ),
      // 底部导航菜单栏
      bottomNavigationBar: new BottomNavigationBar(items: <BottomNavigationBarItem>[
        /// 参数一icon 图标
        BottomNavigationBarItem(icon: Icon(Icons.home,color: index==0?Colors.blue:Colors.grey),title:Text("首页",style: TextStyle(color: index==0?Colors.blue:Colors.grey))),
        BottomNavigationBarItem(icon: Icon(Icons.email,color: index==1?Colors.blue:Colors.grey),title: Text("邮箱",style: TextStyle(color: index==1?Colors.blue:Colors.grey))),
        BottomNavigationBarItem(icon: Icon(Icons.people,color: index==2?Colors.blue:Colors.grey),title: Text("我的",style: TextStyle(color: index==2?Colors.blue:Colors.grey))),
      ],
       /// BottomNavigationBar 的点击事件
       onTap: (flag){
        print("flag $flag");
        index = flag;
        setState(() {

        });
       },
       /// 当前显示的页面
       currentIndex: index,
      ),
    );
  }
}
